package main

import "fmt"

type Command interface {
	Execute()
}

type SendMsg struct {
	Phone   string
	Content string
}

func (s *SendMsg) Execute() {
	fmt.Println("发送短信给：", s.Phone, "内容：", s.Content)
}

type SendEmail struct {
	Email   string
	Content string
}

func (s *SendEmail) Execute() {
	fmt.Println("发送邮件给：", s.Email, "内容：", s.Content)
}

type TaskQueue struct {
	Queue []Command
}

func (t *TaskQueue) AddTask(c Command) {
	t.Queue = append(t.Queue, c)
}

func (t *TaskQueue) Run() {
	for _, v := range t.Queue {
		v.Execute()
	}
}

func main() {
	taskQueue := &TaskQueue{}
	taskQueue.AddTask(&SendEmail{"shirongjie@gmail.com", "hello world"})
	taskQueue.AddTask(&SendMsg{"18769027732", "hello world"})
	taskQueue.Run()
}
